//
//  ThreeViewController.m
//  UI07_UINavigationController
//
//  Created by aaaaaa on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ThreeViewController.h"
#include "FourViewController.h"

@interface ThreeViewController ()

@end

@implementation ThreeViewController

//将要显现
- (void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden = YES;
    NSLog(@"%d, %s", __LINE__, __FUNCTION__);
}


//将要消失
/** **/
- (void)viewWillDisappear:(BOOL)animated{
    self.navigationController.navigationBarHidden = NO;
     NSLog(@"%d, %s", __LINE__, __FUNCTION__);
}









- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    
    self.title = @"Three";
    //隐藏导航栏
//    self.navigationController.navigationBarHidden = YES;
    
    [self createButton];
    [self createNextButton];
}

- (void)createButton{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(100, 100, 100, 50);
    [button setTitle:@"返回第一页" forState:UIControlStateNormal];
    button.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)buttonAction:(UIButton *)button{
    //返回根视图控制器
    [self.navigationController popToRootViewControllerAnimated:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)createNextButton{
    UIButton *next = [UIButton buttonWithType:UIButtonTypeSystem];
    next.frame = CGRectMake(100, 300, 100, 100);
    [next setTitle:@"下一页" forState:UIControlStateNormal];
    [self.view addSubview:next];
    [next addTarget:self action:@selector(nextAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)nextAction:(UIButton *)button{
    FourViewController *fourVc = [[FourViewController alloc] init];
    [self.navigationController pushViewController:fourVc animated:YES];
    [fourVc release];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
